package com.zhou.base.components.feign.simple.feign;

import com.zhou.base.components.bs.common.model.Response;
import com.zhou.base.components.feign.simple.feign.config.TestFeignConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * @author xianfeng
 * @date 2023/11/22 17:54
 * @description:
 */
@FeignClient(name = "${test.url.name:feign-example1}", url = "http://localhost:8081", path = "/test", configuration = {TestFeignConfiguration.class})
public interface TestUrlFeign {

    @GetMapping("/getToken")
    Response<String> getToken(@RequestParam String appKey, @RequestParam String appSecret);

    @GetMapping("/queryByAuth")
    Response<String> queryByAuth(@RequestParam String param);

    @GetMapping("/query/error")
    Response<String> queryWithError(@RequestParam String param);

    @GetMapping("/query/errorStatus")
    Response<String> queryWithErrorStatus(@RequestParam String param);

    @GetMapping("/test111111")
    Response<String> query404();

    @GetMapping("")
    Response<String> queryNormal(@RequestParam String param);

    /**
     * consumes： 指定处理请求的提交内容类型（Content-Type），例如application/json, text/html;
     * produces:    指定返回的内容类型，仅当request请求头中的(Accept)类型中包含该指定类型才返回；
     *
     * @param file
     * @param headers
     * @return
     */
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    Response<String> upload(@RequestPart("file") MultipartFile file, @RequestHeader Map<String, Object> headers);

}
